package org.benxiong.iplay.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Constants {

	public static final String			CLIENT_ID			= "iplay";

	public static final String			DOWNLOAD_FILE_DESC	= "IPlay";

	public static String				DEVICE_INFO			= "Unknown";

	// apk file name
	public static final String			APK_NAME			= "Iplay.apk";

	// GCM Sender Id, it's generated from URL when browsing Google API access
	// console
	public static final String			GCM_SENDER_ID		= "137894781208";	// IPlayId:
																				// 137894781208

	public static Map<String, String>	COUNTRY_NAMES;

	static {

		COUNTRY_NAMES = new TreeMap<String, String>(new Comparator<String>() {
			@Override
			public int compare(String s1, String s2) {
				return s1.compareTo(s2);
			}
		});

		COUNTRY_NAMES.put("AD", "Andorra");
		COUNTRY_NAMES.put("AE", "United Arab Emirates");
		COUNTRY_NAMES.put("AF", "Afghanistan");
		COUNTRY_NAMES.put("AG", "Antigua and Barbuda");
		COUNTRY_NAMES.put("AI", "Anguilla");
		COUNTRY_NAMES.put("AL", "Albania");
		COUNTRY_NAMES.put("AM", "Armenia");
		COUNTRY_NAMES.put("AO", "Angola");
		COUNTRY_NAMES.put("AQ", "Antarctica");
		COUNTRY_NAMES.put("AR", "Argentina");
		COUNTRY_NAMES.put("AS", "American Samoa");
		COUNTRY_NAMES.put("AT", "Austria");
		COUNTRY_NAMES.put("AU", "Australia");
		COUNTRY_NAMES.put("AW", "Aruba");
		COUNTRY_NAMES.put("AX", "�land Islands");
		COUNTRY_NAMES.put("AZ", "Azerbaijan");
		COUNTRY_NAMES.put("BA", "Bosnia and Herzegovina");
		COUNTRY_NAMES.put("BB", "Barbados");
		COUNTRY_NAMES.put("BD", "Bangladesh");
		COUNTRY_NAMES.put("BE", "Belgium");
		COUNTRY_NAMES.put("BF", "Burkina Faso");
		COUNTRY_NAMES.put("BG", "Bulgaria");
		COUNTRY_NAMES.put("BH", "Bahrain");
		COUNTRY_NAMES.put("BI", "Burundi");
		COUNTRY_NAMES.put("BJ", "Benin");
		COUNTRY_NAMES.put("BL", "Saint Barth�lemy");
		COUNTRY_NAMES.put("BM", "Bermuda");
		COUNTRY_NAMES.put("BN", "Brunei Darussalam");
		COUNTRY_NAMES.put("BO", "Bolivia, Plurinational State of");
		COUNTRY_NAMES.put("BQ", "Bonaire, Sint Eustatius and Saba");
		COUNTRY_NAMES.put("BR", "Brazil");
		COUNTRY_NAMES.put("BS", "Bahamas");
		COUNTRY_NAMES.put("BT", "Bhutan");
		COUNTRY_NAMES.put("BV", "Bouvet Island");
		COUNTRY_NAMES.put("BW", "Botswana");
		COUNTRY_NAMES.put("BY", "Belarus");
		COUNTRY_NAMES.put("BZ", "Belize");
		COUNTRY_NAMES.put("CA", "Canada");
		COUNTRY_NAMES.put("CC", "Cocos (Keeling) Islands");
		COUNTRY_NAMES.put("CD", "Congo, the Democratic Republic of the");
		COUNTRY_NAMES.put("CF", "Central African Republic");
		COUNTRY_NAMES.put("CG", "Congo");
		COUNTRY_NAMES.put("CH", "Switzerland");
		COUNTRY_NAMES.put("CI", "C�te d'Ivoire");
		COUNTRY_NAMES.put("CK", "Cook Islands");
		COUNTRY_NAMES.put("CL", "Chile");
		COUNTRY_NAMES.put("CM", "Cameroon");
		COUNTRY_NAMES.put("CN", "China");
		COUNTRY_NAMES.put("CO", "Colombia");
		COUNTRY_NAMES.put("CR", "Costa Rica");
		COUNTRY_NAMES.put("CU", "Cuba");
		COUNTRY_NAMES.put("CV", "Cape Verde");
		COUNTRY_NAMES.put("CW", "Cura�ao");
		COUNTRY_NAMES.put("CX", "Christmas Island");
		COUNTRY_NAMES.put("CY", "Cyprus");
		COUNTRY_NAMES.put("CZ", "Czech Republic");
		COUNTRY_NAMES.put("DE", "Germany");
		COUNTRY_NAMES.put("DJ", "Djibouti");
		COUNTRY_NAMES.put("DK", "Denmark");
		COUNTRY_NAMES.put("DM", "Dominica");
		COUNTRY_NAMES.put("DO", "Dominican Republic");
		COUNTRY_NAMES.put("DZ", "Algeria");
		COUNTRY_NAMES.put("EC", "Ecuador");
		COUNTRY_NAMES.put("EE", "Estonia");
		COUNTRY_NAMES.put("EG", "Egypt");
		COUNTRY_NAMES.put("EH", "Western Sahara");
		COUNTRY_NAMES.put("ER", "Eritrea");
		COUNTRY_NAMES.put("ES", "Spain");
		COUNTRY_NAMES.put("ET", "Ethiopia");
		COUNTRY_NAMES.put("FI", "Finland");
		COUNTRY_NAMES.put("FJ", "Fiji");
		COUNTRY_NAMES.put("FK", "Falkland Islands (Malvinas)");
		COUNTRY_NAMES.put("FM", "Micronesia, Federated States of");
		COUNTRY_NAMES.put("FO", "Faroe Islands");
		COUNTRY_NAMES.put("FR", "France");
		COUNTRY_NAMES.put("GA", "Gabon");
		COUNTRY_NAMES.put("GB", "United Kingdom");
		COUNTRY_NAMES.put("GD", "Grenada");
		COUNTRY_NAMES.put("GE", "Georgia");
		COUNTRY_NAMES.put("GF", "French Guiana");
		COUNTRY_NAMES.put("GG", "Guernsey");
		COUNTRY_NAMES.put("GH", "Ghana");
		COUNTRY_NAMES.put("GI", "Gibraltar");
		COUNTRY_NAMES.put("GL", "Greenland");
		COUNTRY_NAMES.put("GM", "Gambia");
		COUNTRY_NAMES.put("GN", "Guinea");
		COUNTRY_NAMES.put("GP", "Guadeloupe");
		COUNTRY_NAMES.put("GQ", "Equatorial Guinea");
		COUNTRY_NAMES.put("GR", "Greece");
		COUNTRY_NAMES.put("GS", "South Georgia and the South Sandwich Islands");
		COUNTRY_NAMES.put("GT", "Guatemala");
		COUNTRY_NAMES.put("GU", "Guam");
		COUNTRY_NAMES.put("GW", "Guinea-Bissau");
		COUNTRY_NAMES.put("GY", "Guyana");
		COUNTRY_NAMES.put("HK", "Hong Kong");
		COUNTRY_NAMES.put("HM", "Heard Island and McDonald Islands");
		COUNTRY_NAMES.put("HN", "Honduras");
		COUNTRY_NAMES.put("HR", "Croatia");
		COUNTRY_NAMES.put("HT", "Haiti");
		COUNTRY_NAMES.put("HU", "Hungary");
		COUNTRY_NAMES.put("ID", "Indonesia");
		COUNTRY_NAMES.put("IE", "Ireland");
		COUNTRY_NAMES.put("IL", "Israel");
		COUNTRY_NAMES.put("IM", "Isle of Man");
		COUNTRY_NAMES.put("IN", "India");
		COUNTRY_NAMES.put("IO", "British Indian Ocean Territory");
		COUNTRY_NAMES.put("IQ", "Iraq");
		COUNTRY_NAMES.put("IR", "Iran, Islamic Republic of");
		COUNTRY_NAMES.put("IS", "Iceland");
		COUNTRY_NAMES.put("IT", "Italy");
		COUNTRY_NAMES.put("JE", "Jersey");
		COUNTRY_NAMES.put("JM", "Jamaica");
		COUNTRY_NAMES.put("JO", "Jordan");
		COUNTRY_NAMES.put("JP", "Japan");
		COUNTRY_NAMES.put("KE", "Kenya");
		COUNTRY_NAMES.put("KG", "Kyrgyzstan");
		COUNTRY_NAMES.put("KH", "Cambodia");
		COUNTRY_NAMES.put("KI", "Kiribati");
		COUNTRY_NAMES.put("KM", "Comoros");
		COUNTRY_NAMES.put("KN", "Saint Kitts and Nevis");
		COUNTRY_NAMES.put("KP", "Korea, Democratic People's Republic of");
		COUNTRY_NAMES.put("KR", "Korea, Republic of");
		COUNTRY_NAMES.put("KW", "Kuwait");
		COUNTRY_NAMES.put("KY", "Cayman Islands");
		COUNTRY_NAMES.put("KZ", "Kazakhstan");
		COUNTRY_NAMES.put("LA", "Lao People's Democratic Republic");
		COUNTRY_NAMES.put("LB", "Lebanon");
		COUNTRY_NAMES.put("LC", "Saint Lucia");
		COUNTRY_NAMES.put("LI", "Liechtenstein");
		COUNTRY_NAMES.put("LK", "Sri Lanka");
		COUNTRY_NAMES.put("LR", "Liberia");
		COUNTRY_NAMES.put("LS", "Lesotho");
		COUNTRY_NAMES.put("LT", "Lithuania");
		COUNTRY_NAMES.put("LU", "Luxembourg");
		COUNTRY_NAMES.put("LV", "Latvia");
		COUNTRY_NAMES.put("LY", "Libyan Arab Jamahiriya");
		COUNTRY_NAMES.put("MA", "Morocco");
		COUNTRY_NAMES.put("MC", "Monaco");
		COUNTRY_NAMES.put("MD", "Moldova, Republic of");
		COUNTRY_NAMES.put("ME", "Montenegro");
		COUNTRY_NAMES.put("MF", "Saint Martin (French part)");
		COUNTRY_NAMES.put("MG", "Madagascar");
		COUNTRY_NAMES.put("MH", "Marshall Islands");
		COUNTRY_NAMES.put("ML", "Mali");
		COUNTRY_NAMES.put("MM", "Myanmar");
		COUNTRY_NAMES.put("MO", "Macao");
		COUNTRY_NAMES.put("MQ", "Martinique");
		COUNTRY_NAMES.put("MS", "Montserrat");
		COUNTRY_NAMES.put("MT", "Malta");
		COUNTRY_NAMES.put("MU", "Mauritius");
		COUNTRY_NAMES.put("MV", "Maldives");
		COUNTRY_NAMES.put("MX", "Mexico");
		COUNTRY_NAMES.put("MY", "Malaysia");
		COUNTRY_NAMES.put("MZ", "Mozambique");
		COUNTRY_NAMES.put("NE", "Niger");
		COUNTRY_NAMES.put("NI", "Nicaragua");
		COUNTRY_NAMES.put("NL", "Netherlands");
		COUNTRY_NAMES.put("NO", "Norway");
		COUNTRY_NAMES.put("NR", "Nauru");
		COUNTRY_NAMES.put("NZ", "New Zealand");
		COUNTRY_NAMES.put("PA", "Panama");
		COUNTRY_NAMES.put("PE", "Peru");
		COUNTRY_NAMES.put("PF", "French Polynesia");
		COUNTRY_NAMES.put("PG", "Papua New Guinea");
		COUNTRY_NAMES.put("PH", "Philippines");
		COUNTRY_NAMES.put("PK", "Pakistan");
		COUNTRY_NAMES.put("PL", "Poland");
		COUNTRY_NAMES.put("PM", "Saint Pierre and Miquelon");
		COUNTRY_NAMES.put("PN", "Pitcairn");
		COUNTRY_NAMES.put("PR", "Puerto Rico");
		COUNTRY_NAMES.put("PS", "Palestinian Territory, Occupied");
		COUNTRY_NAMES.put("PT", "Portugal");
		COUNTRY_NAMES.put("PW", "Palau");
		COUNTRY_NAMES.put("PY", "Paraguay");
		COUNTRY_NAMES.put("QA", "Qatar");
		COUNTRY_NAMES.put("RE", "R�union");
		COUNTRY_NAMES.put("RO", "Romania");
		COUNTRY_NAMES.put("RS", "Serbia");
		COUNTRY_NAMES.put("RU", "Russian Federation");
		COUNTRY_NAMES.put("RW", "Rwanda");
		COUNTRY_NAMES.put("SA", "Saudi Arabia");
		COUNTRY_NAMES.put("SB", "Solomon Islands");
		COUNTRY_NAMES.put("SC", "Seychelles");
		COUNTRY_NAMES.put("SD", "Sudan");
		COUNTRY_NAMES.put("SE", "Sweden");
		COUNTRY_NAMES.put("SG", "Singapore");
		COUNTRY_NAMES.put("SH", "Saint Helena, Ascension and Tristan da Cunha");
		COUNTRY_NAMES.put("SI", "Slovenia");
		COUNTRY_NAMES.put("SJ", "Svalbard and Jan Mayen");
		COUNTRY_NAMES.put("SK", "Slovakia");
		COUNTRY_NAMES.put("SL", "Sierra Leone");
		COUNTRY_NAMES.put("SM", "San Marino");
		COUNTRY_NAMES.put("SN", "Senegal");
		COUNTRY_NAMES.put("SO", "Somalia");
		COUNTRY_NAMES.put("SR", "Suriname");
		COUNTRY_NAMES.put("SS", "South Sudan");
		COUNTRY_NAMES.put("ST", "Sao Tome and Principe");
		COUNTRY_NAMES.put("SV", "El Salvador");
		COUNTRY_NAMES.put("SX", "Sint Maarten");
		COUNTRY_NAMES.put("SY", "Syrian Arab Republic");
		COUNTRY_NAMES.put("SZ", "Swaziland");
		COUNTRY_NAMES.put("TC", "Turks and Caicos Islands");
		COUNTRY_NAMES.put("TD", "Chad");
		COUNTRY_NAMES.put("TF", "French Southern Territories");
		COUNTRY_NAMES.put("TG", "Togo");
		COUNTRY_NAMES.put("TH", "Thailand");
		COUNTRY_NAMES.put("TJ", "Tajikistan");
		COUNTRY_NAMES.put("TK", "Tokelau");
		COUNTRY_NAMES.put("TL", "Timor-Leste");
		COUNTRY_NAMES.put("TM", "Turkmenistan");
		COUNTRY_NAMES.put("TN", "Tunisia");
		COUNTRY_NAMES.put("TO", "Tonga");
		COUNTRY_NAMES.put("TR", "Turkey");
		COUNTRY_NAMES.put("TT", "Trinidad and Tobago");
		COUNTRY_NAMES.put("TV", "Tuvalu");
		COUNTRY_NAMES.put("TW", "Taiwan");
		COUNTRY_NAMES.put("TZ", "Tanzania, United Republic of");
		COUNTRY_NAMES.put("UA", "Ukraine");
		COUNTRY_NAMES.put("UG", "Uganda");
		COUNTRY_NAMES.put("UM", "United States Minor Outlying Islands");
		COUNTRY_NAMES.put("US", "United States");
		COUNTRY_NAMES.put("UY", "Uruguay");
		COUNTRY_NAMES.put("UZ", "Uzbekistan");
		COUNTRY_NAMES.put("VA", "Holy See (Vatican City State)");
		COUNTRY_NAMES.put("VC", "Saint Vincent and the Grenadines");
		COUNTRY_NAMES.put("VE", "Venezuela, Bolivarian Republic of");
		COUNTRY_NAMES.put("VG", "Virgin Islands, British");
		COUNTRY_NAMES.put("VI", "Virgin Islands, U.S.");
		COUNTRY_NAMES.put("VN", "Viet Nam");
		COUNTRY_NAMES.put("VU", "Vanuatu");
		COUNTRY_NAMES.put("WF", "Wallis and Futuna");
		COUNTRY_NAMES.put("WS", "Samoa");
		COUNTRY_NAMES.put("YE", "Yemen");
		COUNTRY_NAMES.put("YT", "Mayotte");
		COUNTRY_NAMES.put("ZA", "South Africa");
		COUNTRY_NAMES.put("ZM", "Zambia");
		COUNTRY_NAMES.put("ZW", "Zimbabwe");
	}

	public static List<String> SortedCountryCodesByName() {
		List<String> codes = new ArrayList<String>();
		List<String> names = SortedCountryNames();
		for (String val : names) {
			for(String key: COUNTRY_NAMES.keySet()) {
				if(val.equalsIgnoreCase(COUNTRY_NAMES.get(key))) {
					codes.add(key);
					break;
				}
			}
		}
		return codes;
	}

	public static List<String> SortedCountryNames() {
		List<String> names = new ArrayList<String>(COUNTRY_NAMES.values());
		Collections.sort(names);
		return names;
	}

	public static String CountryCode(String countryName) {
		for (String key : COUNTRY_NAMES.keySet()) {
			if (COUNTRY_NAMES.get(key).equalsIgnoreCase(countryName)) {
				return key;
			}
		}
		return null;
	}

	public static void main(String[] args) {
		System.out.print("codes: " + SortedCountryNames());
	}
}
